<template>
  <view class="apps">
	  <view class="ptb20 plr20 flex fdc" v-if="goods.length >0">
		  <view class="flex bgwhite br15 plr20 ptb20 mb20" v-for="(item,index) in goods" :key="item.id" >
			  <image :src="item.image" class="goods_image" @click="handle('/pages/sale/goods?id='+item.id)"></image>
			  <view class="flex f1 ml20 fdc ptb20">
				<view class="flex aic f13 black">{{item.title}}</view>
				<view class="flex jcsb aic mt20">
					<view class="red f16 b">¥{{item.price}}</view>
					<uv-button type="error" :plain="true"  text="购买" shape="circle" size="small" @click="handle('/pages/sale/goods?id='+item.id)" v-if="showGow == 1"></uv-button>
				</view>
			  </view>
		  </view>
	  </view>
	  <view class="nolist" v-else>
	  <uv-empty mode="list" text="无商品数据"></uv-empty>
	  </view>
	  
  </view>
</template>
<script>
	import { util } from '/common/util.js';
	let app;
	export default {
	  data() {
		return {
		  goods:{},
		  showGow:0,
		}
	  },
	  onLoad() {
		app = this;
		this.getConfig();
		this.getList();
	  },
	  onShow(){
		  this.getList();
	  },
	  methods: {
		async getConfig(){
			const data = await util.request({
				url:'/subscribe/config',
			});
			if(data.code == '200'){
				this.showGow = data.data;
			}
		},
		async getList(){
		 const data = await util.request({
				url:'/subscribe/gdlist',
			});
			if(data.code == '200'){
				this.goods = data.data;
			}
		},
		handle(e){
			uni.navigateTo({
				url:e,
			})
		}
	  }
	}
</script>
<style lang="scss" scoped>
	.goods_image{width:300rpx;height:150rpx;}

</style>

